package com.example.materialdesign1;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by asus on 2018/7/8.
 */

public class ListFragment extends Fragment {
    public static final String ARGS_PAGE="argspage";
    private int mPage;
    private View view;
    private RecyclerView mRecyclerView;
    private List<String> mList = new ArrayList<>();
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view =  inflater.inflate(R.layout.list_frament,container,false);
        mPage=getArguments().getInt("argspage");
        return view;
    }

    public static ListFragment newInstance(int page) {
        
        Bundle args = new Bundle();
        args.putInt(ARGS_PAGE,page);
        ListFragment fragment = new ListFragment();
        fragment.setArguments(args);
        return fragment;
    }
    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        mList.clear();
        switch(mPage){
            case 1:
                mList.add("第"+mPage+"页"+":精选");mList.add("第"+mPage+"页"+":精选");mList.add("第"+mPage+"页"+":精选");
                mList.add("第"+mPage+"页"+":精选");mList.add("第"+mPage+"页"+":精选");mList.add("第"+mPage+"页"+":精选");
                break;
            case 2:
                mList.add("第"+mPage+"页"+":体育");  mList.add("第"+mPage+"页"+":体育"); mList.add("第"+mPage+"页"+":体育");
                mList.add("第"+mPage+"页"+":体育"); mList.add("第"+mPage+"页"+":体育"); mList.add("第"+mPage+"页"+":体育");
                break;
            case 3:
                mList.add("第"+mPage+"页"+":巴萨");  mList.add("第"+mPage+"页"+":巴萨"); mList.add("第"+mPage+"页"+":巴萨");
                mList.add("第"+mPage+"页"+":巴萨"); mList.add("第"+mPage+"页"+":巴萨"); mList.add("第"+mPage+"页"+":巴萨");
                break;
            case 4:
                mList.add("第"+mPage+"页"+":购物");  mList.add("第"+mPage+"页"+":购物"); mList.add("第"+mPage+"页"+":购物");
                mList.add("第"+mPage+"页"+":购物"); mList.add("第"+mPage+"页"+":购物"); mList.add("第"+mPage+"页"+":购物");
                break;
            case 5:
                mList.add("第"+mPage+"页"+":明星");  mList.add("第"+mPage+"页"+":明星"); mList.add("第"+mPage+"页"+":明星");
                mList.add("第"+mPage+"页"+":明星"); mList.add("第"+mPage+"页"+":明星"); mList.add("第"+mPage+"页"+":明星");
                break;
            case 6:
                mList.add("第"+mPage+"页"+":视频");  mList.add("第"+mPage+"页"+":视频"); mList.add("第"+mPage+"页"+":视频");
                mList.add("第"+mPage+"页"+":视频"); mList.add("第"+mPage+"页"+":视频"); mList.add("第"+mPage+"页"+":视频");
                break;
            case 7:
                mList.add("第"+mPage+"页"+":健康");  mList.add("第"+mPage+"页"+":健康"); mList.add("第"+mPage+"页"+":健康");
                mList.add("第"+mPage+"页"+":健康"); mList.add("第"+mPage+"页"+":健康"); mList.add("第"+mPage+"页"+":健康");
                break;
            case 8:
                mList.add("第"+mPage+"页"+":你好明天");  mList.add("第"+mPage+"页"+":你好明天"); mList.add("第"+mPage+"页"+":你好明天");
                mList.add("第"+mPage+"页"+":你好明天"); mList.add("第"+mPage+"页"+":你好明天"); mList.add("第"+mPage+"页"+":你好明天");
                break;
            case 9:
                mList.add("第"+mPage+"页"+":你好明天");  mList.add("第"+mPage+"页"+":你好明天"); mList.add("第"+mPage+"页"+":你好明天");
                mList.add("第"+mPage+"页"+":你好明天"); mList.add("第"+mPage+"页"+":你好明天"); mList.add("第"+mPage+"页"+":你好明天");
                break;
            case 10:
                mList.add("第"+mPage+"页"+":你好明天");  mList.add("第"+mPage+"页"+":你好明天"); mList.add("第"+mPage+"页"+":你好明天");
                mList.add("第"+mPage+"页"+":你好明天"); mList.add("第"+mPage+"页"+":你好明天"); mList.add("第"+mPage+"页"+":你好明天");
                break;
            case 11:
                mList.add("第"+mPage+"页"+":你好明天");  mList.add("第"+mPage+"页"+":你好明天"); mList.add("第"+mPage+"页"+":你好明天");
                mList.add("第"+mPage+"页"+":你好明天"); mList.add("第"+mPage+"页"+":你好明天"); mList.add("第"+mPage+"页"+":你好明天");
                break;
            case 12:
                mList.add("第"+mPage+"页"+":你好明天");  mList.add("第"+mPage+"页"+":你好明天"); mList.add("第"+mPage+"页"+":你好明天");
                mList.add("第"+mPage+"页"+":你好明天"); mList.add("第"+mPage+"页"+":你好明天"); mList.add("第"+mPage+"页"+":你好明天");
                break;
                default:
                    mList.add("第"+mPage+"页"+":你好明天");  mList.add("第"+mPage+"页"+":你好明天"); mList.add("第"+mPage+"页"+":你好明天");
                    mList.add("第"+mPage+"页"+":你好明天"); mList.add("第"+mPage+"页"+":你好明天"); mList.add("第"+mPage+"页"+":你好明天");
                    break;
        }
        mRecyclerView = view.findViewById(R.id.recycler_view);
        mRecyclerView.setLayoutManager(new LinearLayoutManager(mRecyclerView.getContext()));
        mRecyclerView.setAdapter(new RecyclerViewAdapter(getActivity(),mList));
    }
}
